﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IntelligentAgriculture.Domain.Interface
{
    public interface IBaseRepository<T> where T : class
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">要添加的实体</param>
        /// <returns>返回受影响的行数</returns>
        int Add(T entity);
        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns>返回所有数据</returns>
        IQueryable<T> GetQuery();
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">要修改的实体</param>
        /// <returns>返回受影响的行数</returns>
        int Update(T entity);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="entities">要修改的实体集合</param>
        /// <returns>返回受影响的行数</returns>
        int UpdateRange(List<T> entities);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">要删除的实体</param>
        /// <returns>受影响的行数</returns>
        int Delete(T entity);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="entities">要删除的实体集合</param>
        /// <returns>返回受影响的行数</returns>
        int DeleteRange(List<T> entities);
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T Get(int id);
    }
}
